package com.example.sse.model;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 实时数据模型
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RealtimeData {

    /**
     * 数据ID
     */
    @JSONField(name = "id")
    private String id;

    /**
     * 数据类型
     */
    @JSONField(name = "type")
    private String type;

    /**
     * 数据内容
     */
    @JSONField(name = "content")
    private Object content;

    /**
     * 时间戳
     */
    @JSONField(name = "timestamp", format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime timestamp;

    /**
     * 服务器节点ID
     */
    @JSONField(name = "nodeId")
    private String nodeId;

    /**
     * 消息类型枚举
     */
    public enum MessageType {
        SYSTEM_INFO("system_info", "系统信息"),
        USER_ACTIVITY("user_activity", "用户活动"),
        ORDER_UPDATE("order_update", "订单更新"),
        PAYMENT_NOTIFY("payment_notify", "支付通知"),
        HEARTBEAT("heartbeat", "心跳检测");

        private final String code;
        private final String description;

        MessageType(String code, String description) {
            this.code = code;
            this.description = description;
        }

        public String getCode() { return code; }
        public String getDescription() { return description; }
    }
}